﻿///////////////////////////////////////////////////////////////
// This is generated code. 
//////////////////////////////////////////////////////////////
// Code is generated using LLBLGen Pro version: 2.6
// Code is generated on: 
// Code is generated using templates: SD.TemplateBindings.SharedTemplates.NET20
// Templates vendor: Solutions Design.
// Templates version: 
//////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using Northwinddemo.DAL.EntityClasses;
using Northwinddemo.DAL.HelperClasses;
using Northwinddemo.DAL.RelationClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;

namespace Northwinddemo.DAL.FactoryClasses
{
	
	// __LLBLGENPRO_USER_CODE_REGION_START AdditionalNamespaces
	// __LLBLGENPRO_USER_CODE_REGION_END
	
	/// <summary>general base class for the generated factories</summary>
	[Serializable]
	public partial class EntityFactoryBase2 : EntityFactoryCore2
	{
		private string _entityName;
		private Northwinddemo.DAL.EntityType _typeOfEntity;
		
		/// <summary>CTor</summary>
		/// <param name="entityName">Name of the entity.</param>
		/// <param name="typeOfEntity">The type of entity.</param>
		public EntityFactoryBase2(string entityName, Northwinddemo.DAL.EntityType typeOfEntity)
		{
			_entityName = entityName;
			_typeOfEntity = typeOfEntity;
		}
		
		/// <summary>Creates, using the generated EntityFieldsFactory, the IEntityFields2 object for the entity to create.</summary>
		/// <returns>Empty IEntityFields2 object.</returns>
		public override IEntityFields2 CreateFields()
		{
			return EntityFieldsFactory.CreateEntityFieldsObject(_typeOfEntity);
		}
		
		/// <summary>Creates a new entity instance using the GeneralEntityFactory in the generated code, using the passed in entitytype value</summary>
		/// <param name="entityTypeValue">The entity type value of the entity to create an instance for.</param>
		/// <returns>new IEntity instance</returns>
		public override IEntity2 CreateEntityFromEntityTypeValue(int entityTypeValue)
		{
			return GeneralEntityFactory.Create((Northwinddemo.DAL.EntityType)entityTypeValue);
		}

		/// <summary>Creates the relations collection to the entity to join all targets so this entity can be fetched. </summary>
		/// <param name="objectAlias">The object alias to use for the elements in the relations.</param>
		/// <returns>null if the entity isn't in a hierarchy of type TargetPerEntity, otherwise the relations collection needed to join all targets together to fetch all subtypes of this entity and this entity itself</returns>
		public override IRelationCollection CreateHierarchyRelations(string objectAlias) 
		{
			return InheritanceInfoProviderSingleton.GetInstance().GetHierarchyRelations(_entityName, objectAlias);
		}

		/// <summary>This method retrieves, using the InheritanceInfoprovider, the factory for the entity represented by the values passed in.</summary>
		/// <param name="fieldValues">Field values read from the db, to determine which factory to return, based on the field values passed in.</param>
		/// <param name="entityFieldStartIndexesPerEntity">indexes into values where per entity type their own fields start.</param>
		/// <returns>the factory for the entity which is represented by the values passed in.</returns>
		public override IEntityFactory2 GetEntityFactory(object[] fieldValues, Dictionary<string, int> entityFieldStartIndexesPerEntity) 
		{
			IEntityFactory2 toReturn = (IEntityFactory2)InheritanceInfoProviderSingleton.GetInstance().GetEntityFactory(_entityName, fieldValues, entityFieldStartIndexesPerEntity);
			if(toReturn == null)
			{
				toReturn = this;
			}
			return toReturn;
		}
		
		/// <summary>Gets a predicateexpression which filters on the entity with type belonging to this factory.</summary>
		/// <param name="negate">Flag to produce a NOT filter, (true), or a normal filter (false). </param>
		/// <param name="objectAlias">The object alias to use for the predicate(s).</param>
		/// <returns>ready to use predicateexpression, or an empty predicate expression if the belonging entity isn't a hierarchical type.</returns>
		public override IPredicateExpression GetEntityTypeFilter(bool negate, string objectAlias) 
		{
			return InheritanceInfoProviderSingleton.GetInstance().GetEntityTypeFilter(this.ForEntityName, objectAlias, negate);
		}
				
		/// <summary>returns the name of the entity this factory is for, e.g. "EmployeeEntity"</summary>
		public override string ForEntityName 
		{ 
			get { return _entityName; }
		}
	}
	
	/// <summary>Factory to create new, empty AlphabeticalListOfProductsEntity objects.</summary>
	[Serializable]
	public partial class AlphabeticalListOfProductsEntityFactory : EntityFactoryBase2 {
		/// <summary>CTor</summary>
		public AlphabeticalListOfProductsEntityFactory() : base("AlphabeticalListOfProductsEntity", Northwinddemo.DAL.EntityType.AlphabeticalListOfProductsEntity) { }

		/// <summary>Creates a new, empty AlphabeticalListOfProductsEntity object.</summary>
		/// <returns>A new, empty AlphabeticalListOfProductsEntity object.</returns>
		public override IEntity2 Create() {
			IEntity2 toReturn = new AlphabeticalListOfProductsEntity();
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewAlphabeticalListOfProducts
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new AlphabeticalListOfProductsEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new AlphabeticalListOfProductsEntity(fields);
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewAlphabeticalListOfProductsUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		/// <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		public override IEntityCollection2 CreateEntityCollection()
		{
			return new EntityCollection<AlphabeticalListOfProductsEntity>(this);
		}
		

		#region Included Code

		#endregion
	}	
	/// <summary>Factory to create new, empty CategoriesEntity objects.</summary>
	[Serializable]
	public partial class CategoriesEntityFactory : EntityFactoryBase2 {
		/// <summary>CTor</summary>
		public CategoriesEntityFactory() : base("CategoriesEntity", Northwinddemo.DAL.EntityType.CategoriesEntity) { }

		/// <summary>Creates a new, empty CategoriesEntity object.</summary>
		/// <returns>A new, empty CategoriesEntity object.</returns>
		public override IEntity2 Create() {
			IEntity2 toReturn = new CategoriesEntity();
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewCategories
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new CategoriesEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new CategoriesEntity(fields);
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewCategoriesUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		/// <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		public override IEntityCollection2 CreateEntityCollection()
		{
			return new EntityCollection<CategoriesEntity>(this);
		}
		

		#region Included Code

		#endregion
	}	
	/// <summary>Factory to create new, empty CategorySalesFor1997Entity objects.</summary>
	[Serializable]
	public partial class CategorySalesFor1997EntityFactory : EntityFactoryBase2 {
		/// <summary>CTor</summary>
		public CategorySalesFor1997EntityFactory() : base("CategorySalesFor1997Entity", Northwinddemo.DAL.EntityType.CategorySalesFor1997Entity) { }

		/// <summary>Creates a new, empty CategorySalesFor1997Entity object.</summary>
		/// <returns>A new, empty CategorySalesFor1997Entity object.</returns>
		public override IEntity2 Create() {
			IEntity2 toReturn = new CategorySalesFor1997Entity();
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewCategorySalesFor1997
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new CategorySalesFor1997Entity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new CategorySalesFor1997Entity(fields);
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewCategorySalesFor1997UsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		/// <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		public override IEntityCollection2 CreateEntityCollection()
		{
			return new EntityCollection<CategorySalesFor1997Entity>(this);
		}
		

		#region Included Code

		#endregion
	}	
	/// <summary>Factory to create new, empty CurrentProductListEntity objects.</summary>
	[Serializable]
	public partial class CurrentProductListEntityFactory : EntityFactoryBase2 {
		/// <summary>CTor</summary>
		public CurrentProductListEntityFactory() : base("CurrentProductListEntity", Northwinddemo.DAL.EntityType.CurrentProductListEntity) { }

		/// <summary>Creates a new, empty CurrentProductListEntity object.</summary>
		/// <returns>A new, empty CurrentProductListEntity object.</returns>
		public override IEntity2 Create() {
			IEntity2 toReturn = new CurrentProductListEntity();
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewCurrentProductList
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new CurrentProductListEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new CurrentProductListEntity(fields);
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewCurrentProductListUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		/// <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		public override IEntityCollection2 CreateEntityCollection()
		{
			return new EntityCollection<CurrentProductListEntity>(this);
		}
		

		#region Included Code

		#endregion
	}	
	/// <summary>Factory to create new, empty CustomerAndSuppliersByCityEntity objects.</summary>
	[Serializable]
	public partial class CustomerAndSuppliersByCityEntityFactory : EntityFactoryBase2 {
		/// <summary>CTor</summary>
		public CustomerAndSuppliersByCityEntityFactory() : base("CustomerAndSuppliersByCityEntity", Northwinddemo.DAL.EntityType.CustomerAndSuppliersByCityEntity) { }

		/// <summary>Creates a new, empty CustomerAndSuppliersByCityEntity object.</summary>
		/// <returns>A new, empty CustomerAndSuppliersByCityEntity object.</returns>
		public override IEntity2 Create() {
			IEntity2 toReturn = new CustomerAndSuppliersByCityEntity();
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewCustomerAndSuppliersByCity
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new CustomerAndSuppliersByCityEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new CustomerAndSuppliersByCityEntity(fields);
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewCustomerAndSuppliersByCityUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		/// <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		public override IEntityCollection2 CreateEntityCollection()
		{
			return new EntityCollection<CustomerAndSuppliersByCityEntity>(this);
		}
		

		#region Included Code

		#endregion
	}	
	/// <summary>Factory to create new, empty CustomerCustomerDemoEntity objects.</summary>
	[Serializable]
	public partial class CustomerCustomerDemoEntityFactory : EntityFactoryBase2 {
		/// <summary>CTor</summary>
		public CustomerCustomerDemoEntityFactory() : base("CustomerCustomerDemoEntity", Northwinddemo.DAL.EntityType.CustomerCustomerDemoEntity) { }

		/// <summary>Creates a new, empty CustomerCustomerDemoEntity object.</summary>
		/// <returns>A new, empty CustomerCustomerDemoEntity object.</returns>
		public override IEntity2 Create() {
			IEntity2 toReturn = new CustomerCustomerDemoEntity();
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewCustomerCustomerDemo
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new CustomerCustomerDemoEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new CustomerCustomerDemoEntity(fields);
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewCustomerCustomerDemoUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		/// <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		public override IEntityCollection2 CreateEntityCollection()
		{
			return new EntityCollection<CustomerCustomerDemoEntity>(this);
		}
		

		#region Included Code

		#endregion
	}	
	/// <summary>Factory to create new, empty CustomerDemographicsEntity objects.</summary>
	[Serializable]
	public partial class CustomerDemographicsEntityFactory : EntityFactoryBase2 {
		/// <summary>CTor</summary>
		public CustomerDemographicsEntityFactory() : base("CustomerDemographicsEntity", Northwinddemo.DAL.EntityType.CustomerDemographicsEntity) { }

		/// <summary>Creates a new, empty CustomerDemographicsEntity object.</summary>
		/// <returns>A new, empty CustomerDemographicsEntity object.</returns>
		public override IEntity2 Create() {
			IEntity2 toReturn = new CustomerDemographicsEntity();
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewCustomerDemographics
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new CustomerDemographicsEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new CustomerDemographicsEntity(fields);
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewCustomerDemographicsUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		/// <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		public override IEntityCollection2 CreateEntityCollection()
		{
			return new EntityCollection<CustomerDemographicsEntity>(this);
		}
		

		#region Included Code

		#endregion
	}	
	/// <summary>Factory to create new, empty CustomersEntity objects.</summary>
	[Serializable]
	public partial class CustomersEntityFactory : EntityFactoryBase2 {
		/// <summary>CTor</summary>
		public CustomersEntityFactory() : base("CustomersEntity", Northwinddemo.DAL.EntityType.CustomersEntity) { }

		/// <summary>Creates a new, empty CustomersEntity object.</summary>
		/// <returns>A new, empty CustomersEntity object.</returns>
		public override IEntity2 Create() {
			IEntity2 toReturn = new CustomersEntity();
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewCustomers
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new CustomersEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new CustomersEntity(fields);
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewCustomersUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		/// <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		public override IEntityCollection2 CreateEntityCollection()
		{
			return new EntityCollection<CustomersEntity>(this);
		}
		

		#region Included Code

		#endregion
	}	
	/// <summary>Factory to create new, empty EmployeesEntity objects.</summary>
	[Serializable]
	public partial class EmployeesEntityFactory : EntityFactoryBase2 {
		/// <summary>CTor</summary>
		public EmployeesEntityFactory() : base("EmployeesEntity", Northwinddemo.DAL.EntityType.EmployeesEntity) { }

		/// <summary>Creates a new, empty EmployeesEntity object.</summary>
		/// <returns>A new, empty EmployeesEntity object.</returns>
		public override IEntity2 Create() {
			IEntity2 toReturn = new EmployeesEntity();
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewEmployees
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new EmployeesEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new EmployeesEntity(fields);
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewEmployeesUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		/// <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		public override IEntityCollection2 CreateEntityCollection()
		{
			return new EntityCollection<EmployeesEntity>(this);
		}
		

		#region Included Code

		#endregion
	}	
	/// <summary>Factory to create new, empty EmployeeTerritoriesEntity objects.</summary>
	[Serializable]
	public partial class EmployeeTerritoriesEntityFactory : EntityFactoryBase2 {
		/// <summary>CTor</summary>
		public EmployeeTerritoriesEntityFactory() : base("EmployeeTerritoriesEntity", Northwinddemo.DAL.EntityType.EmployeeTerritoriesEntity) { }

		/// <summary>Creates a new, empty EmployeeTerritoriesEntity object.</summary>
		/// <returns>A new, empty EmployeeTerritoriesEntity object.</returns>
		public override IEntity2 Create() {
			IEntity2 toReturn = new EmployeeTerritoriesEntity();
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewEmployeeTerritories
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new EmployeeTerritoriesEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new EmployeeTerritoriesEntity(fields);
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewEmployeeTerritoriesUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		/// <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		public override IEntityCollection2 CreateEntityCollection()
		{
			return new EntityCollection<EmployeeTerritoriesEntity>(this);
		}
		

		#region Included Code

		#endregion
	}	
	/// <summary>Factory to create new, empty InvoicesEntity objects.</summary>
	[Serializable]
	public partial class InvoicesEntityFactory : EntityFactoryBase2 {
		/// <summary>CTor</summary>
		public InvoicesEntityFactory() : base("InvoicesEntity", Northwinddemo.DAL.EntityType.InvoicesEntity) { }

		/// <summary>Creates a new, empty InvoicesEntity object.</summary>
		/// <returns>A new, empty InvoicesEntity object.</returns>
		public override IEntity2 Create() {
			IEntity2 toReturn = new InvoicesEntity();
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewInvoices
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new InvoicesEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new InvoicesEntity(fields);
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewInvoicesUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		/// <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		public override IEntityCollection2 CreateEntityCollection()
		{
			return new EntityCollection<InvoicesEntity>(this);
		}
		

		#region Included Code

		#endregion
	}	
	/// <summary>Factory to create new, empty OrderDetailsEntity objects.</summary>
	[Serializable]
	public partial class OrderDetailsEntityFactory : EntityFactoryBase2 {
		/// <summary>CTor</summary>
		public OrderDetailsEntityFactory() : base("OrderDetailsEntity", Northwinddemo.DAL.EntityType.OrderDetailsEntity) { }

		/// <summary>Creates a new, empty OrderDetailsEntity object.</summary>
		/// <returns>A new, empty OrderDetailsEntity object.</returns>
		public override IEntity2 Create() {
			IEntity2 toReturn = new OrderDetailsEntity();
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewOrderDetails
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new OrderDetailsEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new OrderDetailsEntity(fields);
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewOrderDetailsUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		/// <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		public override IEntityCollection2 CreateEntityCollection()
		{
			return new EntityCollection<OrderDetailsEntity>(this);
		}
		

		#region Included Code

		#endregion
	}	
	/// <summary>Factory to create new, empty OrderDetailsExtendedEntity objects.</summary>
	[Serializable]
	public partial class OrderDetailsExtendedEntityFactory : EntityFactoryBase2 {
		/// <summary>CTor</summary>
		public OrderDetailsExtendedEntityFactory() : base("OrderDetailsExtendedEntity", Northwinddemo.DAL.EntityType.OrderDetailsExtendedEntity) { }

		/// <summary>Creates a new, empty OrderDetailsExtendedEntity object.</summary>
		/// <returns>A new, empty OrderDetailsExtendedEntity object.</returns>
		public override IEntity2 Create() {
			IEntity2 toReturn = new OrderDetailsExtendedEntity();
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewOrderDetailsExtended
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new OrderDetailsExtendedEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new OrderDetailsExtendedEntity(fields);
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewOrderDetailsExtendedUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		/// <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		public override IEntityCollection2 CreateEntityCollection()
		{
			return new EntityCollection<OrderDetailsExtendedEntity>(this);
		}
		

		#region Included Code

		#endregion
	}	
	/// <summary>Factory to create new, empty OrdersEntity objects.</summary>
	[Serializable]
	public partial class OrdersEntityFactory : EntityFactoryBase2 {
		/// <summary>CTor</summary>
		public OrdersEntityFactory() : base("OrdersEntity", Northwinddemo.DAL.EntityType.OrdersEntity) { }

		/// <summary>Creates a new, empty OrdersEntity object.</summary>
		/// <returns>A new, empty OrdersEntity object.</returns>
		public override IEntity2 Create() {
			IEntity2 toReturn = new OrdersEntity();
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewOrders
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new OrdersEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new OrdersEntity(fields);
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewOrdersUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		/// <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		public override IEntityCollection2 CreateEntityCollection()
		{
			return new EntityCollection<OrdersEntity>(this);
		}
		

		#region Included Code

		#endregion
	}	
	/// <summary>Factory to create new, empty OrdersQryEntity objects.</summary>
	[Serializable]
	public partial class OrdersQryEntityFactory : EntityFactoryBase2 {
		/// <summary>CTor</summary>
		public OrdersQryEntityFactory() : base("OrdersQryEntity", Northwinddemo.DAL.EntityType.OrdersQryEntity) { }

		/// <summary>Creates a new, empty OrdersQryEntity object.</summary>
		/// <returns>A new, empty OrdersQryEntity object.</returns>
		public override IEntity2 Create() {
			IEntity2 toReturn = new OrdersQryEntity();
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewOrdersQry
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new OrdersQryEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new OrdersQryEntity(fields);
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewOrdersQryUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		/// <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		public override IEntityCollection2 CreateEntityCollection()
		{
			return new EntityCollection<OrdersQryEntity>(this);
		}
		

		#region Included Code

		#endregion
	}	
	/// <summary>Factory to create new, empty OrderSubtotalsEntity objects.</summary>
	[Serializable]
	public partial class OrderSubtotalsEntityFactory : EntityFactoryBase2 {
		/// <summary>CTor</summary>
		public OrderSubtotalsEntityFactory() : base("OrderSubtotalsEntity", Northwinddemo.DAL.EntityType.OrderSubtotalsEntity) { }

		/// <summary>Creates a new, empty OrderSubtotalsEntity object.</summary>
		/// <returns>A new, empty OrderSubtotalsEntity object.</returns>
		public override IEntity2 Create() {
			IEntity2 toReturn = new OrderSubtotalsEntity();
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewOrderSubtotals
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new OrderSubtotalsEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new OrderSubtotalsEntity(fields);
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewOrderSubtotalsUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		/// <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		public override IEntityCollection2 CreateEntityCollection()
		{
			return new EntityCollection<OrderSubtotalsEntity>(this);
		}
		

		#region Included Code

		#endregion
	}	
	/// <summary>Factory to create new, empty ProductsEntity objects.</summary>
	[Serializable]
	public partial class ProductsEntityFactory : EntityFactoryBase2 {
		/// <summary>CTor</summary>
		public ProductsEntityFactory() : base("ProductsEntity", Northwinddemo.DAL.EntityType.ProductsEntity) { }

		/// <summary>Creates a new, empty ProductsEntity object.</summary>
		/// <returns>A new, empty ProductsEntity object.</returns>
		public override IEntity2 Create() {
			IEntity2 toReturn = new ProductsEntity();
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewProducts
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new ProductsEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new ProductsEntity(fields);
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewProductsUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		/// <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		public override IEntityCollection2 CreateEntityCollection()
		{
			return new EntityCollection<ProductsEntity>(this);
		}
		

		#region Included Code

		#endregion
	}	
	/// <summary>Factory to create new, empty ProductsAboveAveragePriceEntity objects.</summary>
	[Serializable]
	public partial class ProductsAboveAveragePriceEntityFactory : EntityFactoryBase2 {
		/// <summary>CTor</summary>
		public ProductsAboveAveragePriceEntityFactory() : base("ProductsAboveAveragePriceEntity", Northwinddemo.DAL.EntityType.ProductsAboveAveragePriceEntity) { }

		/// <summary>Creates a new, empty ProductsAboveAveragePriceEntity object.</summary>
		/// <returns>A new, empty ProductsAboveAveragePriceEntity object.</returns>
		public override IEntity2 Create() {
			IEntity2 toReturn = new ProductsAboveAveragePriceEntity();
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewProductsAboveAveragePrice
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new ProductsAboveAveragePriceEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new ProductsAboveAveragePriceEntity(fields);
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewProductsAboveAveragePriceUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		/// <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		public override IEntityCollection2 CreateEntityCollection()
		{
			return new EntityCollection<ProductsAboveAveragePriceEntity>(this);
		}
		

		#region Included Code

		#endregion
	}	
	/// <summary>Factory to create new, empty ProductSalesFor1997Entity objects.</summary>
	[Serializable]
	public partial class ProductSalesFor1997EntityFactory : EntityFactoryBase2 {
		/// <summary>CTor</summary>
		public ProductSalesFor1997EntityFactory() : base("ProductSalesFor1997Entity", Northwinddemo.DAL.EntityType.ProductSalesFor1997Entity) { }

		/// <summary>Creates a new, empty ProductSalesFor1997Entity object.</summary>
		/// <returns>A new, empty ProductSalesFor1997Entity object.</returns>
		public override IEntity2 Create() {
			IEntity2 toReturn = new ProductSalesFor1997Entity();
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewProductSalesFor1997
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new ProductSalesFor1997Entity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new ProductSalesFor1997Entity(fields);
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewProductSalesFor1997UsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		/// <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		public override IEntityCollection2 CreateEntityCollection()
		{
			return new EntityCollection<ProductSalesFor1997Entity>(this);
		}
		

		#region Included Code

		#endregion
	}	
	/// <summary>Factory to create new, empty ProductsByCategoryEntity objects.</summary>
	[Serializable]
	public partial class ProductsByCategoryEntityFactory : EntityFactoryBase2 {
		/// <summary>CTor</summary>
		public ProductsByCategoryEntityFactory() : base("ProductsByCategoryEntity", Northwinddemo.DAL.EntityType.ProductsByCategoryEntity) { }

		/// <summary>Creates a new, empty ProductsByCategoryEntity object.</summary>
		/// <returns>A new, empty ProductsByCategoryEntity object.</returns>
		public override IEntity2 Create() {
			IEntity2 toReturn = new ProductsByCategoryEntity();
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewProductsByCategory
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new ProductsByCategoryEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new ProductsByCategoryEntity(fields);
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewProductsByCategoryUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		/// <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		public override IEntityCollection2 CreateEntityCollection()
		{
			return new EntityCollection<ProductsByCategoryEntity>(this);
		}
		

		#region Included Code

		#endregion
	}	
	/// <summary>Factory to create new, empty QuarterlyOrdersEntity objects.</summary>
	[Serializable]
	public partial class QuarterlyOrdersEntityFactory : EntityFactoryBase2 {
		/// <summary>CTor</summary>
		public QuarterlyOrdersEntityFactory() : base("QuarterlyOrdersEntity", Northwinddemo.DAL.EntityType.QuarterlyOrdersEntity) { }

		/// <summary>Creates a new, empty QuarterlyOrdersEntity object.</summary>
		/// <returns>A new, empty QuarterlyOrdersEntity object.</returns>
		public override IEntity2 Create() {
			IEntity2 toReturn = new QuarterlyOrdersEntity();
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewQuarterlyOrders
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new QuarterlyOrdersEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new QuarterlyOrdersEntity(fields);
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewQuarterlyOrdersUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		/// <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		public override IEntityCollection2 CreateEntityCollection()
		{
			return new EntityCollection<QuarterlyOrdersEntity>(this);
		}
		

		#region Included Code

		#endregion
	}	
	/// <summary>Factory to create new, empty RegionEntity objects.</summary>
	[Serializable]
	public partial class RegionEntityFactory : EntityFactoryBase2 {
		/// <summary>CTor</summary>
		public RegionEntityFactory() : base("RegionEntity", Northwinddemo.DAL.EntityType.RegionEntity) { }

		/// <summary>Creates a new, empty RegionEntity object.</summary>
		/// <returns>A new, empty RegionEntity object.</returns>
		public override IEntity2 Create() {
			IEntity2 toReturn = new RegionEntity();
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewRegion
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new RegionEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new RegionEntity(fields);
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewRegionUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		/// <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		public override IEntityCollection2 CreateEntityCollection()
		{
			return new EntityCollection<RegionEntity>(this);
		}
		

		#region Included Code

		#endregion
	}	
	/// <summary>Factory to create new, empty SalesByCategoryEntity objects.</summary>
	[Serializable]
	public partial class SalesByCategoryEntityFactory : EntityFactoryBase2 {
		/// <summary>CTor</summary>
		public SalesByCategoryEntityFactory() : base("SalesByCategoryEntity", Northwinddemo.DAL.EntityType.SalesByCategoryEntity) { }

		/// <summary>Creates a new, empty SalesByCategoryEntity object.</summary>
		/// <returns>A new, empty SalesByCategoryEntity object.</returns>
		public override IEntity2 Create() {
			IEntity2 toReturn = new SalesByCategoryEntity();
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewSalesByCategory
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new SalesByCategoryEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new SalesByCategoryEntity(fields);
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewSalesByCategoryUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		/// <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		public override IEntityCollection2 CreateEntityCollection()
		{
			return new EntityCollection<SalesByCategoryEntity>(this);
		}
		

		#region Included Code

		#endregion
	}	
	/// <summary>Factory to create new, empty SalesTotalsByAmountEntity objects.</summary>
	[Serializable]
	public partial class SalesTotalsByAmountEntityFactory : EntityFactoryBase2 {
		/// <summary>CTor</summary>
		public SalesTotalsByAmountEntityFactory() : base("SalesTotalsByAmountEntity", Northwinddemo.DAL.EntityType.SalesTotalsByAmountEntity) { }

		/// <summary>Creates a new, empty SalesTotalsByAmountEntity object.</summary>
		/// <returns>A new, empty SalesTotalsByAmountEntity object.</returns>
		public override IEntity2 Create() {
			IEntity2 toReturn = new SalesTotalsByAmountEntity();
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewSalesTotalsByAmount
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new SalesTotalsByAmountEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new SalesTotalsByAmountEntity(fields);
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewSalesTotalsByAmountUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		/// <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		public override IEntityCollection2 CreateEntityCollection()
		{
			return new EntityCollection<SalesTotalsByAmountEntity>(this);
		}
		

		#region Included Code

		#endregion
	}	
	/// <summary>Factory to create new, empty ShippersEntity objects.</summary>
	[Serializable]
	public partial class ShippersEntityFactory : EntityFactoryBase2 {
		/// <summary>CTor</summary>
		public ShippersEntityFactory() : base("ShippersEntity", Northwinddemo.DAL.EntityType.ShippersEntity) { }

		/// <summary>Creates a new, empty ShippersEntity object.</summary>
		/// <returns>A new, empty ShippersEntity object.</returns>
		public override IEntity2 Create() {
			IEntity2 toReturn = new ShippersEntity();
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewShippers
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new ShippersEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new ShippersEntity(fields);
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewShippersUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		/// <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		public override IEntityCollection2 CreateEntityCollection()
		{
			return new EntityCollection<ShippersEntity>(this);
		}
		

		#region Included Code

		#endregion
	}	
	/// <summary>Factory to create new, empty SummaryOfSalesByQuarterEntity objects.</summary>
	[Serializable]
	public partial class SummaryOfSalesByQuarterEntityFactory : EntityFactoryBase2 {
		/// <summary>CTor</summary>
		public SummaryOfSalesByQuarterEntityFactory() : base("SummaryOfSalesByQuarterEntity", Northwinddemo.DAL.EntityType.SummaryOfSalesByQuarterEntity) { }

		/// <summary>Creates a new, empty SummaryOfSalesByQuarterEntity object.</summary>
		/// <returns>A new, empty SummaryOfSalesByQuarterEntity object.</returns>
		public override IEntity2 Create() {
			IEntity2 toReturn = new SummaryOfSalesByQuarterEntity();
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewSummaryOfSalesByQuarter
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new SummaryOfSalesByQuarterEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new SummaryOfSalesByQuarterEntity(fields);
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewSummaryOfSalesByQuarterUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		/// <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		public override IEntityCollection2 CreateEntityCollection()
		{
			return new EntityCollection<SummaryOfSalesByQuarterEntity>(this);
		}
		

		#region Included Code

		#endregion
	}	
	/// <summary>Factory to create new, empty SummaryOfSalesByYearEntity objects.</summary>
	[Serializable]
	public partial class SummaryOfSalesByYearEntityFactory : EntityFactoryBase2 {
		/// <summary>CTor</summary>
		public SummaryOfSalesByYearEntityFactory() : base("SummaryOfSalesByYearEntity", Northwinddemo.DAL.EntityType.SummaryOfSalesByYearEntity) { }

		/// <summary>Creates a new, empty SummaryOfSalesByYearEntity object.</summary>
		/// <returns>A new, empty SummaryOfSalesByYearEntity object.</returns>
		public override IEntity2 Create() {
			IEntity2 toReturn = new SummaryOfSalesByYearEntity();
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewSummaryOfSalesByYear
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new SummaryOfSalesByYearEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new SummaryOfSalesByYearEntity(fields);
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewSummaryOfSalesByYearUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		/// <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		public override IEntityCollection2 CreateEntityCollection()
		{
			return new EntityCollection<SummaryOfSalesByYearEntity>(this);
		}
		

		#region Included Code

		#endregion
	}	
	/// <summary>Factory to create new, empty SuppliersEntity objects.</summary>
	[Serializable]
	public partial class SuppliersEntityFactory : EntityFactoryBase2 {
		/// <summary>CTor</summary>
		public SuppliersEntityFactory() : base("SuppliersEntity", Northwinddemo.DAL.EntityType.SuppliersEntity) { }

		/// <summary>Creates a new, empty SuppliersEntity object.</summary>
		/// <returns>A new, empty SuppliersEntity object.</returns>
		public override IEntity2 Create() {
			IEntity2 toReturn = new SuppliersEntity();
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewSuppliers
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new SuppliersEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new SuppliersEntity(fields);
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewSuppliersUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		/// <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		public override IEntityCollection2 CreateEntityCollection()
		{
			return new EntityCollection<SuppliersEntity>(this);
		}
		

		#region Included Code

		#endregion
	}	
	/// <summary>Factory to create new, empty TerritoriesEntity objects.</summary>
	[Serializable]
	public partial class TerritoriesEntityFactory : EntityFactoryBase2 {
		/// <summary>CTor</summary>
		public TerritoriesEntityFactory() : base("TerritoriesEntity", Northwinddemo.DAL.EntityType.TerritoriesEntity) { }

		/// <summary>Creates a new, empty TerritoriesEntity object.</summary>
		/// <returns>A new, empty TerritoriesEntity object.</returns>
		public override IEntity2 Create() {
			IEntity2 toReturn = new TerritoriesEntity();
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewTerritories
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new TerritoriesEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new TerritoriesEntity(fields);
			
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewTerritoriesUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		
		/// <summary>Creates a new generic EntityCollection(Of T) for the entity to which this factory belongs.</summary>
		/// <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		public override IEntityCollection2 CreateEntityCollection()
		{
			return new EntityCollection<TerritoriesEntity>(this);
		}
		

		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty Entity objects based on the entity type specified. Uses  entity specific factory objects</summary>
	[Serializable]
	public partial class GeneralEntityFactory
	{
		/// <summary>Creates a new, empty Entity object of the type specified</summary>
		/// <param name="entityTypeToCreate">The entity type to create.</param>
		/// <returns>A new, empty Entity object.</returns>
		public static IEntity2 Create(Northwinddemo.DAL.EntityType entityTypeToCreate)
		{
			IEntityFactory2 factoryToUse = null;
			switch(entityTypeToCreate)
			{
				case Northwinddemo.DAL.EntityType.AlphabeticalListOfProductsEntity:
					factoryToUse = new AlphabeticalListOfProductsEntityFactory();
					break;
				case Northwinddemo.DAL.EntityType.CategoriesEntity:
					factoryToUse = new CategoriesEntityFactory();
					break;
				case Northwinddemo.DAL.EntityType.CategorySalesFor1997Entity:
					factoryToUse = new CategorySalesFor1997EntityFactory();
					break;
				case Northwinddemo.DAL.EntityType.CurrentProductListEntity:
					factoryToUse = new CurrentProductListEntityFactory();
					break;
				case Northwinddemo.DAL.EntityType.CustomerAndSuppliersByCityEntity:
					factoryToUse = new CustomerAndSuppliersByCityEntityFactory();
					break;
				case Northwinddemo.DAL.EntityType.CustomerCustomerDemoEntity:
					factoryToUse = new CustomerCustomerDemoEntityFactory();
					break;
				case Northwinddemo.DAL.EntityType.CustomerDemographicsEntity:
					factoryToUse = new CustomerDemographicsEntityFactory();
					break;
				case Northwinddemo.DAL.EntityType.CustomersEntity:
					factoryToUse = new CustomersEntityFactory();
					break;
				case Northwinddemo.DAL.EntityType.EmployeesEntity:
					factoryToUse = new EmployeesEntityFactory();
					break;
				case Northwinddemo.DAL.EntityType.EmployeeTerritoriesEntity:
					factoryToUse = new EmployeeTerritoriesEntityFactory();
					break;
				case Northwinddemo.DAL.EntityType.InvoicesEntity:
					factoryToUse = new InvoicesEntityFactory();
					break;
				case Northwinddemo.DAL.EntityType.OrderDetailsEntity:
					factoryToUse = new OrderDetailsEntityFactory();
					break;
				case Northwinddemo.DAL.EntityType.OrderDetailsExtendedEntity:
					factoryToUse = new OrderDetailsExtendedEntityFactory();
					break;
				case Northwinddemo.DAL.EntityType.OrdersEntity:
					factoryToUse = new OrdersEntityFactory();
					break;
				case Northwinddemo.DAL.EntityType.OrdersQryEntity:
					factoryToUse = new OrdersQryEntityFactory();
					break;
				case Northwinddemo.DAL.EntityType.OrderSubtotalsEntity:
					factoryToUse = new OrderSubtotalsEntityFactory();
					break;
				case Northwinddemo.DAL.EntityType.ProductsEntity:
					factoryToUse = new ProductsEntityFactory();
					break;
				case Northwinddemo.DAL.EntityType.ProductsAboveAveragePriceEntity:
					factoryToUse = new ProductsAboveAveragePriceEntityFactory();
					break;
				case Northwinddemo.DAL.EntityType.ProductSalesFor1997Entity:
					factoryToUse = new ProductSalesFor1997EntityFactory();
					break;
				case Northwinddemo.DAL.EntityType.ProductsByCategoryEntity:
					factoryToUse = new ProductsByCategoryEntityFactory();
					break;
				case Northwinddemo.DAL.EntityType.QuarterlyOrdersEntity:
					factoryToUse = new QuarterlyOrdersEntityFactory();
					break;
				case Northwinddemo.DAL.EntityType.RegionEntity:
					factoryToUse = new RegionEntityFactory();
					break;
				case Northwinddemo.DAL.EntityType.SalesByCategoryEntity:
					factoryToUse = new SalesByCategoryEntityFactory();
					break;
				case Northwinddemo.DAL.EntityType.SalesTotalsByAmountEntity:
					factoryToUse = new SalesTotalsByAmountEntityFactory();
					break;
				case Northwinddemo.DAL.EntityType.ShippersEntity:
					factoryToUse = new ShippersEntityFactory();
					break;
				case Northwinddemo.DAL.EntityType.SummaryOfSalesByQuarterEntity:
					factoryToUse = new SummaryOfSalesByQuarterEntityFactory();
					break;
				case Northwinddemo.DAL.EntityType.SummaryOfSalesByYearEntity:
					factoryToUse = new SummaryOfSalesByYearEntityFactory();
					break;
				case Northwinddemo.DAL.EntityType.SuppliersEntity:
					factoryToUse = new SuppliersEntityFactory();
					break;
				case Northwinddemo.DAL.EntityType.TerritoriesEntity:
					factoryToUse = new TerritoriesEntityFactory();
					break;
			}
			IEntity2 toReturn = null;
			if(factoryToUse != null)
			{
				toReturn = factoryToUse.Create();
			}
			return toReturn;
		}		
	}
		
	/// <summary>Class which is used to obtain the entity factory based on the .NET type of the entity. </summary>
	[Serializable]
	public static class EntityFactoryFactory
	{
#if CF
		/// <summary>Gets the factory of the entity with the Northwinddemo.DAL.EntityType specified</summary>
		/// <param name="typeOfEntity">The type of entity.</param>
		/// <returns>factory to use or null if not found</returns>
		public static IEntityFactory2 GetFactory(Northwinddemo.DAL.EntityType typeOfEntity)
		{
			return GeneralEntityFactory.Create(typeOfEntity).GetEntityFactory();
		}
#else
		private static Dictionary<Type, IEntityFactory2> _factoryPerType = new Dictionary<Type, IEntityFactory2>();

		/// <summary>Initializes the <see cref="EntityFactoryFactory"/> class.</summary>
		static EntityFactoryFactory()
		{
			Array entityTypeValues = Enum.GetValues(typeof(Northwinddemo.DAL.EntityType));
			foreach(int entityTypeValue in entityTypeValues)
			{
				IEntity2 dummy = GeneralEntityFactory.Create((Northwinddemo.DAL.EntityType)entityTypeValue);
				_factoryPerType.Add(dummy.GetType(), dummy.GetEntityFactory());
			}
		}

		/// <summary>Gets the factory of the entity with the .NET type specified</summary>
		/// <param name="typeOfEntity">The type of entity.</param>
		/// <returns>factory to use or null if not found</returns>
		public static IEntityFactory2 GetFactory(Type typeOfEntity)
		{
			IEntityFactory2 toReturn = null;
			_factoryPerType.TryGetValue(typeOfEntity, out toReturn);
			return toReturn;
		}

		/// <summary>Gets the factory of the entity with the Northwinddemo.DAL.EntityType specified</summary>
		/// <param name="typeOfEntity">The type of entity.</param>
		/// <returns>factory to use or null if not found</returns>
		public static IEntityFactory2 GetFactory(Northwinddemo.DAL.EntityType typeOfEntity)
		{
			return GetFactory(GeneralEntityFactory.Create(typeOfEntity).GetType());
		}
#endif		
	}
		
	/// <summary>Element creator for creating project elements from somewhere else, like inside Linq providers.</summary>
	public class ElementCreator : ElementCreatorBase, IElementCreator2
	{
		/// <summary>Gets the factory of the Entity type with the Northwinddemo.DAL.EntityType value passed in</summary>
		/// <param name="entityTypeValue">The entity type value.</param>
		/// <returns>the entity factory of the entity type or null if not found</returns>
		public IEntityFactory2 GetFactory(int entityTypeValue)
		{
			return (IEntityFactory2)this.GetFactoryImpl(entityTypeValue);
		}
		
		/// <summary>Gets the factory of the Entity type with the .NET type passed in</summary>
		/// <param name="typeOfEntity">The type of entity.</param>
		/// <returns>the entity factory of the entity type or null if not found</returns>
		public IEntityFactory2 GetFactory(Type typeOfEntity)
		{
			return (IEntityFactory2)this.GetFactoryImpl(typeOfEntity);
		}

		/// <summary>Creates a new resultset fields object with the number of field slots reserved as specified</summary>
		/// <param name="numberOfFields">The number of fields.</param>
		/// <returns>ready to use resultsetfields object</returns>
		public IEntityFields2 CreateResultsetFields(int numberOfFields)
		{
			return new ResultsetFields(numberOfFields);
		}

		/// <summary>Creates a new dynamic relation instance</summary>
		/// <param name="leftOperand">The left operand.</param>
		/// <returns>ready to use dynamic relation</returns>
		public override IDynamicRelation CreateDynamicRelation(DerivedTableDefinition leftOperand)
		{
			return new DynamicRelation(leftOperand);
		}

		/// <summary>Creates a new dynamic relation instance</summary>
		/// <param name="leftOperand">The left operand.</param>
		/// <param name="joinType">Type of the join. If None is specified, Inner is assumed.</param>
		/// <param name="rightOperand">The right operand.</param>
		/// <param name="onClause">The on clause for the join.</param>
		/// <returns>ready to use dynamic relation</returns>
		public override IDynamicRelation CreateDynamicRelation(DerivedTableDefinition leftOperand, JoinHint joinType, DerivedTableDefinition rightOperand, IPredicate onClause)
		{
			return new DynamicRelation(leftOperand, joinType, rightOperand, onClause);
		}

		/// <summary>Creates a new dynamic relation instance</summary>
		/// <param name="leftOperand">The left operand.</param>
		/// <param name="joinType">Type of the join. If None is specified, Inner is assumed.</param>
		/// <param name="rightOperandEntityName">Name of the entity, which is used as the right operand.</param>
		/// <param name="aliasRightOperand">The alias of the right operand. If you don't want to / need to alias the right operand (only alias if you have to), specify string.Empty.</param>
		/// <param name="onClause">The on clause for the join.</param>
		/// <returns>ready to use dynamic relation</returns>
		public override IDynamicRelation CreateDynamicRelation(DerivedTableDefinition leftOperand, JoinHint joinType, string rightOperandEntityName, string aliasRightOperand, IPredicate onClause)
		{
			return new DynamicRelation(leftOperand, joinType, (Northwinddemo.DAL.EntityType)Enum.Parse(typeof(Northwinddemo.DAL.EntityType), rightOperandEntityName, false), aliasRightOperand, onClause);
		}

		/// <summary>Creates a new dynamic relation instance</summary>
		/// <param name="leftOperandEntityName">Name of the entity which is used as the left operand.</param>
		/// <param name="joinType">Type of the join. If None is specified, Inner is assumed.</param>
		/// <param name="rightOperandEntityName">Name of the entity, which is used as the right operand.</param>
		/// <param name="aliasLeftOperand">The alias of the left operand. If you don't want to / need to alias the right operand (only alias if you have to), specify string.Empty.</param>
		/// <param name="aliasRightOperand">The alias of the right operand. If you don't want to / need to alias the right operand (only alias if you have to), specify string.Empty.</param>
		/// <param name="onClause">The on clause for the join.</param>
		/// <returns>ready to use dynamic relation</returns>
		public override IDynamicRelation CreateDynamicRelation(string leftOperandEntityName, JoinHint joinType, string rightOperandEntityName, string aliasLeftOperand, string aliasRightOperand, IPredicate onClause)
		{
			return new DynamicRelation((Northwinddemo.DAL.EntityType)Enum.Parse(typeof(Northwinddemo.DAL.EntityType), leftOperandEntityName, false), joinType, (Northwinddemo.DAL.EntityType)Enum.Parse(typeof(Northwinddemo.DAL.EntityType), rightOperandEntityName, false), aliasLeftOperand, aliasRightOperand, onClause);
		}
		
		/// <summary>Obtains the inheritance info provider instance from the singleton </summary>
		/// <returns>The singleton instance of the inheritance info provider</returns>
		public override IInheritanceInfoProvider ObtainInheritanceInfoProviderInstance()
		{
			return InheritanceInfoProviderSingleton.GetInstance();
		}
		
		/// <summary>Implementation of the routine which gets the factory of the Entity type with the Northwinddemo.DAL.EntityType value passed in</summary>
		/// <param name="entityTypeValue">The entity type value.</param>
		/// <returns>the entity factory of the entity type or null if not found</returns>
		protected override IEntityFactoryCore GetFactoryImpl(int entityTypeValue)
		{
			return EntityFactoryFactory.GetFactory((Northwinddemo.DAL.EntityType)entityTypeValue);
		}
#if !CF		
		/// <summary>Implementation of the routine which gets the factory of the Entity type with the .NET type passed in</summary>
		/// <param name="typeOfEntity">The type of entity.</param>
		/// <returns>the entity factory of the entity type or null if not found</returns>
		protected override IEntityFactoryCore GetFactoryImpl(Type typeOfEntity)
		{
			return EntityFactoryFactory.GetFactory(typeOfEntity);
		}
#endif
	}
}
